
FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["Student.API/Student.API.csproj", "Student.API/"]
COPY ["Student.DTO/Student.DTO.csproj", "Student.DTO/"]
COPY ["Student.Model/Student.Model.csproj", "Student.Model/"]
COPY ["yrjw.CommonToolsCore/yrjw.CommonToolsCore.csproj", "yrjw.CommonToolsCore/"]
COPY ["Student.Services/Student.Services.csproj", "Student.Services/"]
COPY ["Auth.Jwt/Auth.Jwt.csproj", "Auth.Jwt/"]
COPY ["Student.IServices/Student.IServices.csproj", "Student.IServices/"]
COPY ["Cache.MemoryCache/Cache.MemoryCache.csproj", "Cache.MemoryCache/"]

#RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev
#RUN ln -s /usr/lib/libgdiplus.so /usr/lib/gdiplus.dll

RUN dotnet restore "Student.API/Student.API.csproj"
COPY . .
WORKDIR "/src/Student.API"
RUN dotnet build "Student.API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Student.API.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Student.API.dll"]